/**
 * @param {string} s
 * @return {number}
 */
var numSub = function (s) {
  const MOD = 10 ** 9 + 7;
  let result = 0;
  let currentLength = 0;

  for (let char of s) {
    if (char === "1") {
      currentLength++;
    } else {
      // 遇到 '0'，计算当前连续 '1' 片段的子字符串数量
      result = (result + (currentLength * (currentLength + 1)) / 2) % MOD;
      currentLength = 0;
    }
  }

  // 处理字符串末尾的连续 '1' 片段
  result = (result + (currentLength * (currentLength + 1)) / 2) % MOD;

  return result;
};
